package factoryNCastle;


import extra.Position;

import constants.*;
import agents.AgentBombermanCastle;
import agents.AgentEnemyCastle;
import agents.AgentFungi;
import agents.AgentMoney;
import agents.AgentUpdateCastle;
import agents.interaction.InteractionGenerateMonster;
import agents.interaction.InteractionMoveObject;
import agents.interaction.InteractionMoveRandom;
import interfaces.impl.agents.AgentDrawLife;
import interfaces.impl.agents.AgentMove;
import objects.ImageObject;
import objects.SpetialFeature;
import objects.WorldObject;

public abstract class ObjectFactory {
	
	public static int objectID = 0;
	
	public final static WorldObject createWorldObject(int id){
		WorldObject object= new WorldObject();
		
		object.setID(objectID);
		objectID++;
		object.setObjectReference(id);
		object.setImageObject(ImageObjectFactory.createImageObject(id));
		/*int x = (int)(object.getPosition().getX()-object.getImageObject().getImageToShow().getWidth()/2);
		int y = (int)(object.getPosition().getY()-object.getImageObject().getImageToShow().getHeight()/2);
		object.setPosition(new Position(x,y));*/
		
		switch (id){
		case Constants.OBJECT_REFERENCE_BOMBERMAN:

			//object.setObjectReference(id);
			
			//adding actions
			object.addAction(ActionFactory.getAction(Constants.ACTION_MOVE));
			object.addAction(ActionFactory.getAction(Constants.ACTION_ATTACK));
			object.addAction(ActionFactory.getAction(Constants.ACTION_GENERATE_OBJECT));
			object.addAction(ActionFactory.getAction(Constants.ACTION_MODIFY_SPETIAL_FEATURE));
			
			//adding spetials features
			SpetialFeature feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_LIFE);
			feature.setValue(6);
			object.addSpetialFeature(feature);
			
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_CURRENT_LIFE);
			feature.setValue(6);
			object.addSpetialFeature(feature);
			
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_X_TO_MOVE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_Y_TO_MOVE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_IS_MOVING));
			feature=SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_SPEED);
			feature.setValue(0.04);
			object.addSpetialFeature(feature);
			
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_VISION_RANGE));
			
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_DAMAGE);
			feature.setValue(2);
			object.addSpetialFeature(feature);
			
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_ATTACK_TIME);
			feature.setValue(1000);
			object.addSpetialFeature(feature);
			
			//adding agents
			object.addAgent(new AgentDrawLife());
			object.addAgent(new AgentMove());
			object.addAgent(new AgentBombermanCastle());
			
			//adding human Interactions 
			
			
			//
			
			
			return object;
		
		case Constants.OBJECT_REFERENCE_SUGAR:
			object.setObjectReference(id);
			
			return object;
		
		case Constants.OBJECT_REFERENCE_STRAWBERRY:
			object.setObjectReference(id);
			return object;
			
		case Constants.OBJECT_REFERENCE_CASTLE_BLUE:
			object.setObjectReference(id);
			//adding objects
			WorldObject money = createWorldObject(Constants.OBJECT_REFERENCE_MONEY);
			object.addObject(money);
			
			//adding actions
			object.addAction(ActionFactory.getAction(Constants.ACTION_GENERATE_OBJECT));
			object.addAction(ActionFactory.getAction(Constants.ACTION_MODIFY_SPETIAL_FEATURE));
			object.addAction(ActionFactory.getAction(Constants.ACTION_TELEPORT));
			object.addAction(ActionFactory.getAction(Constants.ACTION_ADD_EFFECT));
			//adding specials features
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_LIFE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_CURRENT_LIFE));
			//adding agents
			object.addAgent(new AgentUpdateCastle());
			object.addAgent(new AgentDrawLife());
			object.addHumanInteraction(new InteractionGenerateMonster());
			object.addHumanInteraction(new InteractionMoveObject());
			object.addHumanInteraction(new InteractionMoveRandom());
			//System.out.println("agregue objto dinero "+money.getObjectReference());
			return object;
			
		case Constants.OBJECT_REFERENCE_CASTLE_RED:
			object.setObjectReference(id);
			
			//adding objects
			money = createWorldObject(Constants.OBJECT_REFERENCE_MONEY);
			object.addObject(money);
			
			//adding actions
			object.addAction(ActionFactory.getAction(Constants.ACTION_MODIFY_SPETIAL_FEATURE));
			object.addAction(ActionFactory.getAction(Constants.ACTION_GENERATE_OBJECT));
			object.addAction(ActionFactory.getAction(Constants.ACTION_TELEPORT));
			//adding specials features
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_LIFE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_CURRENT_LIFE));
			//adding agents
			object.addAgent(new AgentUpdateCastle());
			object.addAgent(new AgentEnemyCastle());
			object.addAgent(new AgentDrawLife());
			
			return object;
		case Constants.OBJECT_REFERENCE_MONEY:
			System.err.println("CARGO DINERO");
			object.setObjectReference(id);
			
			//adding actions
			object.addAction(ActionFactory.getAction(Constants.ACTION_INCREASE_MONEY));
			object.addAction(ActionFactory.getAction(Constants.ACTION_MOVE));
			
			
			//adding spetial features
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_MONEY));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_MONEY_TO_INCREASE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_TIME_TO_INCREASE_MONEY));
			
			//adding agents
			object.addAgent(new AgentMoney());
			
			return object;
			
		case Constants.OBJECT_REFERENCE_FUNGI:
			object.setObjectReference(id);
			
			//adding actions
			object.addAction(ActionFactory.getAction(Constants.ACTION_MOVE));
			object.addAction(ActionFactory.getAction(Constants.ACTION_ATTACK));
			object.addAction(ActionFactory.getAction(Constants.ACTION_MODIFY_SPETIAL_FEATURE));
			
			//adding spetials features
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_LIFE);
			feature.setValue(4);
			object.addSpetialFeature(feature);
			
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_CURRENT_LIFE);
			feature.setValue(4);
			object.addSpetialFeature(feature);
			
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_X_TO_MOVE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_Y_TO_MOVE));
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_IS_MOVING));
			
			feature=SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_SPEED);
			feature.setValue(0.07);
			object.addSpetialFeature(feature);
			
			object.addSpetialFeature(SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_VISION_RANGE));
			
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_DAMAGE);
			feature.setValue(1);
			object.addSpetialFeature(feature);
			
			feature = SpetialFeatureFactory.getSpetialFeature(Constants.SPETIAL_FEATURE_ATTACK_TIME);
			feature.setValue(250);
			object.addSpetialFeature(feature);
			
			//adding agents
			object.addAgent(new AgentDrawLife());
			object.addAgent(new AgentMove());
			object.addAgent(new AgentFungi());
				
			return object;
		default:
			object.setObjectReference(Constants.OBJECT_REFERENCE_BOMBERMAN);
			System.out.println("NO ENCUENTRO LA IMAGEN EN OBJECT FACTORY");
			return object;
			
		}
			
		
	}
	
	
	
	
}
